package demo3;

import java.util.Comparator;
import java.util.PriorityQueue;

//无返回值无参数
@FunctionalInterface
interface NoParameterNoReturn {
    void test();
}

//无返回值一个参数
@FunctionalInterface
interface OneParameterNoReturn {
    void test(int a);
}

//无返回值多个参数
@FunctionalInterface
interface MoreParameterNoReturn {
    void test(int a, int b);
}

//有返回值无参数
@FunctionalInterface
interface NoParameterReturn {
    int test();
}

//有返回值一个参数
@FunctionalInterface
interface OneParameterReturn {
    int test(int a);
}

//有返回值多参数
@FunctionalInterface
interface MoreParameterReturn {
    int test(int a, int b);
}

public class Test {
    public static void main(String[] args) {
        NoParameterReturn noParameterReturn = () -> 10;
        System.out.println(noParameterReturn.test());

        OneParameterReturn oneParameterReturn = a -> a + 10;
        System.out.println(oneParameterReturn.test(1));

        MoreParameterReturn moreParameterReturn = (a, b) -> a + b;
        System.out.println(moreParameterReturn.test(11, 20));
    }

    public static void main2(String[] args) {
        NoParameterNoReturn noParameterNoReturn = () -> System.out.println("重写了test方法");
        noParameterNoReturn.test();

        OneParameterNoReturn oneParameterNoReturn = a -> System.out.println("oneParameterNoReturn " + a);
        oneParameterNoReturn.test(10);

        MoreParameterNoReturn moreParameterNoReturn = (a, b) -> System.out.println("moreParameterNoReturn " + a + b);
        moreParameterNoReturn.test(10, 20);
    }

    public static void main1(String[] args) {
        //                                          匿名内部类
        NoParameterNoReturn noParameterNoReturn = new NoParameterNoReturn() {
            @Override
            public void test() {
                System.out.println("重写了test方法");
            }
        };
        noParameterNoReturn.test();

        PriorityQueue<Integer> minHeap = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return 0;
            }
        });

        PriorityQueue<Integer> minHeap2 = new PriorityQueue<>((o1, o2) -> {
            return o1 - o2;
        });
    }
}
